home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / nrpas13.arc / CNTAB1.DEM < prev    next >
Text File  |  1991-05-01  |  1KB  |  64 lines

  1. PROGRAM d13r13(input,output,dfile);
  2. (* driver for routine CNTAB1 *)
  3. (* contingency table in file TABLE1.DAT *)
  4. CONST
  5.    ndat=9;
  6.    nmon=12;
  7. TYPE
  8.    narray = ARRAY [1..ndat,1..nmon] OF integer;
  9.    chr15 = string[15];
  10.    chr5 = string[5];
  11. VAR
  12.    ccc,chisq,cramrv,df,prob : real;
  13.    i,j : integer;
  14.    nmbr : narray;
  15.    fate : ARRAY [1..ndat] OF chr15;
  16.    mon : ARRAY [1..nmon] OF chr5;
  17.    txt : string[64];
  18.    dfile : text;
  19.  
  20. (*$I MODFILE.PAS *)
  21. (*$I GAMMLN.PAS *)
  22.  
  23. (*$I GCF.PAS *)
  24.  
  25. (*$I GSER.PAS *)
  26.  
  27. (*$I GAMMQ.PAS *)
  28.  
  29. (*$I CNTAB1.PAS *)
  30.  
  31. BEGIN
  32.    glopen(dfile,'table1.dat');
  33.    readln(dfile);
  34.    readln(dfile,txt);
  35.    read(dfile,fate[1]);
  36.    FOR i := 1 to 12 DO read(dfile,mon[i]);
  37.    readln(dfile);
  38.    readln(dfile);
  39.    FOR i := 1 to ndat DO BEGIN
  40.       read(dfile,fate[i]);
  41.       FOR j := 1 to 12 DO read(dfile,nmbr[i,j]);
  42.       readln(dfile)
  43.    END;
  44.    close(dfile);
  45.    writeln;
  46.    writeln(txt);
  47.    writeln;
  48.    write(' ':15);
  49.    FOR i := 1 to 12 DO write(mon[i]:5);
  50.    writeln;
  51.    FOR i := 1 to ndat DO BEGIN
  52.       write(fate[i]);
  53.       FOR j := 1 to 12 DO write(nmbr[i,j]:5);
  54.       writeln
  55.    END;
  56.    cntab1(nmbr,ndat,nmon,chisq,df,prob,cramrv,ccc);
  57.    writeln;
  58.    writeln('chi-squared       ',chisq:20:2);
  59.    writeln('degrees of freedom',df:20:2);
  60.    writeln('probability       ',prob:20:4);
  61.    writeln('cramer-v          ',cramrv:20:4);
  62.    writeln('contingency coeff.',ccc:20:4)
  63. END.
  64.